package cn.itsource.controller.app;

import cn.itsource.pojo.domain.Driver;
import cn.itsource.pojo.ro.DriverOnLineRo;
import cn.itsource.pojo.ro.GeoRo;
import cn.itsource.pojo.ro.WxChatRegisterRo;
import cn.itsource.result.JSONResult;
import cn.itsource.service.IDriverService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Tag(name = "司机对象",description = "司机对象")
@RestController
@RequestMapping("/app/driver")
public class AppDriverController {
    @Autowired
    private IDriverService driverService;

    @Operation( summary= "注册Driver",description = "基础对象WX注册接口")
    @Parameter(name = "",description = "请求的参数",required = true)
    @PostMapping
    public JSONResult wxChatRegister(@RequestBody @Valid WxChatRegisterRo registerRo){
        return driverService.wxChatRegister(registerRo);
    }

    @PostMapping("/onLine")
    public JSONResult driverOnLine(@RequestBody @Valid DriverOnLineRo onLineRo){
        return JSONResult.success(driverService.driverOnLine(onLineRo));
    }

    @PostMapping("/offLine")
    public JSONResult driverOffLine(){
        driverService.driverOffLine();
        return JSONResult.success();
    }

    @PostMapping("/geo")
    public JSONResult geo(@RequestBody @Valid GeoRo geoRo){
        driverService.geo(geoRo);
        return JSONResult.success();
    }

}
